/**
 * 中间件工具函数入口文件
 * 提供便捷的中间件使用方法和快捷方式
 */

const { UnifiedAuthMiddleware } = require('./auth.middleware');
const { ComposeMiddleware } = require('./compose.middleware');

/**
 * 中间件工具类
 * 提供统一的中间件管理
 */
class MiddlewareUtils {
    
    // 基础权限控制
    static requireLogin = UnifiedAuthMiddleware.createAuthMiddleware({ requireLogin: true });
    static requireAdmin = UnifiedAuthMiddleware.createAuthMiddleware({ requireAdmin: true });
    
    // 权限验证
    static requireRole = (roles) => UnifiedAuthMiddleware.createAuthMiddleware({ requireLogin: true, requireRole: roles });
    static requirePermission = (permissions) => UnifiedAuthMiddleware.createAuthMiddleware({ requireLogin: true, requirePermission: permissions });
    
    // 组合中间件
    static compose = ComposeMiddleware.compose;
    static createWrapper = ComposeMiddleware.createMiddlewareWrapper;
}

// 导出快捷方式
module.exports = {
    // 基础导出
    UnifiedAuthMiddleware,
    ComposeMiddleware,
    
    // 工具类
    MiddlewareUtils,
    
    // 快捷方式
    requireLogin: MiddlewareUtils.requireLogin,
    requireAdmin: MiddlewareUtils.requireAdmin,
    requireRole: MiddlewareUtils.requireRole,
    requirePermission: MiddlewareUtils.requirePermission,
    compose: MiddlewareUtils.compose,
    createWrapper: MiddlewareUtils.createWrapper
};